<?php

class DarenCateAction extends CommonAction
{
	public function remove()
	{
		//删除指定记录
		$result = array('isErr'=>0,'content'=>'');
		$id = $_REQUEST['id'];
		if(!empty($id))
		{
			$name=$this->getActionName();
			$model = D($name);
			$pk = $model->getPk ();
			$condition = array ($pk => array ('in', explode ( ',', $id ) ) );

			if(D("UserDaren")->where(array ("cid" => array ('in', explode ( ',', $id ) ) ))->count()>0)
			{
				$result['isErr'] = 1;
				$result['content'] = L('DAREN_EXIST');
				die(json_encode($result));
			}

			if(false !== $model->where ( $condition )->delete ())
			{
				$this->saveLog(1,$id);
			}
			else
			{
				$this->saveLog(0,$id);
				$result['isErr'] = 1;
				$result['content'] = L('REMOVE_ERROR');
			}
		}
		else
		{
			$result['isErr'] = 1;
			$result['content'] = L('ACCESS_DENIED');
		}
		
		die(json_encode($result));
	}
}

function getDelLink($is_fix,$id)
{
	if($is_fix == 1)
		return '';
	else
		return '<a href="javascript:;" onclick="removeData(this,'.$id.',\'id\')">'.L('REMOVE').'</a>&nbsp;&nbsp;';	
}
?>